<?php
	session_start();
	require('../Gen_Scripts/gen_functions.php');

	$player_id = $_GET['player_id'];
	if($player_id == ''){
		$player_id = $_POST['player_id'];
	}
	dblogin();
	
?>

<script type="text/javascript">
$(document).ready(function(){
	$('.localhover').cluetip({
		tracking: false,
		splitTitle: '|',
		showTitle: false,
		cluetipClass: 'jtip',
		sticky: false,
		dropShadow: false
	});
});
</script>

	<div id="life" class="full left">	
		<?php
			dblogin();
			$totals =
			"select ifnull(g.type,'NONE') as \"TYPE\", sum(g.amount) as \"AMOUNT\"
			  from PLAYERS p
			  left outer join GAMEPT g
			    on p.player_id = g.player_id
			  where p.player_id = ".$player_id."
			 group by g.type";
			$result = mysql_query($totals);
			while($row = mysql_fetch_array($result)){
				$gp_by_game[$row['TYPE']] = $row['AMOUNT'];
			}
			
			$totals =
			"select sum(g.amount) as \"AMOUNT\"
			  from PLAYERS p
			  left outer join GAMEPT g
				on p.player_id = g.player_id  
			  where p.player_id = ".$player_id;
			$result = mysql_query($totals);
			while($row = mysql_fetch_array($result)){
				$amt = $row['AMOUNT'];
			}
			
			$fill = 1;
			if($amt > 0){
				$fill = floor(600/$amt);
			}
		?>
		<h1> Total GP for <?php echo player_name($player_id); ?> </h1>
		<div id="stats" class ="left" style="width:<?php echo $amt*$fill;?>px">
			<div class="stat bad localhover" style="width: <?php if(isset($gp_by_game['BAD'])){echo $gp_by_game['BAD']*$fill;}else{echo 0;}?>px"
													title="<?php if(isset($gp_by_game['BAD'])){echo $gp_by_game['BAD'];}else{echo 0;}?>"></div>
			<div class="stat rsvp localhover" style="width:<?php if(isset($gp_by_game['RSVP'])){echo $gp_by_game['RSVP']*$fill;}else{echo 0;}?>px"
													title="<?php if(isset($gp_by_game['RSVP'])){echo $gp_by_game['RSVP'];}else{echo 0;}?>"></div>
			<div class="stat bring_item localhover" style="width:<?php if(isset($gp_by_game['ITEM'])){echo $gp_by_game['ITEM']*$fill;}else{echo 0;}?>px" 
													title="<?php if(isset($gp_by_game['ITEM'])){echo $gp_by_game['ITEM'];}else{echo 0;}?>"></div>
			<div class="stat bring_food localhover" style="width:<?php if(isset($gp_by_game['FOOD'])){echo $gp_by_game['FOOD']*$fill;}else{echo 0;}?>px" 
													title="<?php if(isset($gp_by_game['FOOD'])){echo $gp_by_game['FOOD'];}else{echo 0;}?>"></div>
			<div class="stat submitted localhover" style="width:<?php if(isset($gp_by_game['SUB'])){echo $gp_by_game['SUB']*$fill;}else{echo 0;}?>px" 
													title="<?php if(isset($gp_by_game['SUB'])){echo $gp_by_game['SUB'];}else{echo 0;}?>"></div>
			<div class="stat win localhover" style="width:<?php if(isset($gp_by_game['WIN'])){echo $gp_by_game['WIN']*$fill;}else{echo 0;}?>px"
													title=" <?php if(isset($gp_by_game['WIN'])){echo $gp_by_game['WIN'];}else{echo 0;}?>"></div>
			<div class="stat from_game localhover" style="width:<?php if(isset($gp_by_game['GP'])){echo $gp_by_game['GP']*$fill;}else{echo 0;}?>px" 
													title="<?php if(isset($gp_by_game['GP'])){echo $gp_by_game['GP'];}else{echo 0;}?>"></div>
		</div>
		<p class="right"><?php echo $amt; ?> </p>
		<div id="key" class="full left" >
			<label>Penalties</label>				<div class="stat bad key"></div>
			<label>Rsvp</label>						<div class="stat rsvp key"></div>
			<label>Bringing Items</label>			<div class="stat bring_item key"></div>
			<label>Bringing Food</label>			<div class="stat bring_food key"></div>
			<label>Submitting played game</label>	<div class="stat submitted key"></div>
			<label>Winning</label>					<div class="stat win key"></div>
			<label>Regular</label>					<div class="stat from_game key"></div>
		</div>
	</div>
